package com.windmill.ui;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 * @author Jiu
 * @description the base JFrame that each frame extends.
 */
public class BaseFrame extends JFrame {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public BaseFrame() {
		this.setResizable(false);
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		this.setTitle("魔法风车Bate1.0");
		try {
			this.setIconImage(ImageIO.read(getClass().getSuperclass().getResourceAsStream("images/icon1.gif")));
		} catch (IOException e1) {
			//load icon
		}
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				exit();
			}
		});	
	}
	
	public void exit() {
		if(JOptionPane.showConfirmDialog(this, "确定要退出吗？")==JOptionPane.YES_OPTION){			
			System.exit(0);		
		}
	}
}

